<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>

<c:choose>
    <c:when test="${actionBean.roster.id == null}">
        <c:set var="title_key" value="roster.add.title" />
        <c:set var="form_action" value="add" />
    </c:when>
    <c:otherwise>
        <c:set var="title_key" value="roster.edit.title" />
        <c:set var="form_action" value="save" />
    </c:otherwise>
</c:choose>

<f:message key="${title_key}" var="title" />

<s:layout-render name="/layout.jsp" title="${title}">
    <s:layout-component name="content">
       <s:useActionBean beanclass="cz.muni.fi.pa165.sportclubmanager.web.RostersActionBean" var="actionBean"/>           
       
       <h1><f:message key="${title_key}" /></h1>
       
       <s:form beanclass="cz.muni.fi.pa165.sportclubmanager.web.RostersActionBean" class="form">
            <s:errors/>

            <s:hidden name="team.id" value="${actionBean.team.id}" />
            <s:hidden name="player.id" value="${actionBean.player.id}" />
            <s:hidden name="roster.id" value="${actionBean.roster.id}" />

            <div class="form-field">
            <s:label for="r1" name="roster.number"/> <s:text id="r1" name="roster.number"/>
            </div>

            <div class="form-field">
                <s:label for="r2" name="player"/>
                <c:choose>
                <c:when test="${actionBean.roster.id == null}">
                    <s:select id="r2" name="roster.player.id">
                        <s:options-collection collection="${actionBean.allPlayers}" label="lastName" value="id"/>
                    </s:select>
                </c:when>
                <c:otherwise>
                    <s:text id="r2" name="player.lastName" readonly="true" />
                </c:otherwise>
            </c:choose>
            </div>
            
            <div class="form-field form-field-submit">
                <s:submit name="${form_action}" class="button" />
            </div>
        </s:form>
 
    </s:layout-component>
</s:layout-render>